/**
 * Created by Administrator on 2017/11/30.
 */
//var serverUrl= "https://www.pooai.cn/wx/frontend/web/index.php";   //外网路径开始
var serverUrl= "https://www.pooai.cn/wx/frontend/web/index.php";   //本地路径开始
//var serverUrl= "http://192.168.1.105/wx/frontend/web/index.php";   //本地路径开始
//路径
var nUrls = {
    imgBaseUrl:"https://www.pooai.cn/wx/backend/",//图片前缀http://www.pooai.cn/wx/frontend/
    imgFBaseUrl:"https://www.pooai.cn/wx/frontend",//评论上传图片前缀
    imgNativeUrl:"https://www.pooai.cn/wx/frontend",//评论上传图片前缀

    getWxAdUrl:serverUrl+"?r=wxad%2Fwxad%2Findex",//首页微信轮播地址
    getGoodsList:serverUrl+"?r=goods%2Fgoods%2Fgoodslist",//获取商品列表地址
    getGoodsArb:serverUrl+"?r=goods%2Fgoods%2Farb",//获取商品属性信息
    getGoodsInfo:serverUrl+"?r=goods%2Fgoods%2Fgoodinfo",//获得商品信息
    attrGetGoodsInfo:serverUrl+"?r=goods%2Fgoods%2Finfobyattrstring",//通过属性获取商品信息
    getShowGoods:serverUrl+"?r=goods%2Fgoods%2Fshowgoods",//获取推荐产品信息
    getThreeGoodsInfo:serverUrl+"?r=goods%2Fgoods%2Fgetindexgoods",//获取首页三个产品信息

    getAddCollect:serverUrl+"?r=goods%2Fgoods%2Fcollectadd",// 添加收藏接口
    getCollectGoodsInfo:serverUrl+"?r=goods%2Fgoods%2Fgetcollect",//获得收藏夹信息接口
    getGoodsIsCollect:serverUrl+"?r=goods%2Fgoods%2Fiscollect",//商品是否收藏
    getDelCollect:serverUrl+"?r=goods%2Fgoods%2Fcollectdel",//删除收藏

    getAddressListUrl:serverUrl+"?r=address%2Fuseraddress%2Findex",//获取用户地址列表
    addAddress:serverUrl+"?r=address%2Fuseraddress%2Fsetuseradd",//用户添加地址
    deleteAddress:serverUrl+"?r=address%2Fuseraddress%2Fdeladdress",//删除地址
    getDefaultAddress:serverUrl+"?r=address%2Fuseraddress%2Fdefaddress",//获取用户默认地址
    getEditAddress:serverUrl+"?r=address%2Fuseraddress%2Fsetuseredit",//获取编辑地址
    setEditDefaultAddress:serverUrl+"?r=address%2Fuseraddress%2Fsetuseredit",//编辑页面并获取默认地址
    setUserDefaultAddress:serverUrl+"?r=address%2Fuseraddress%2Fsetdef",//设置用户默认地址

    getFaPIaoInfo:serverUrl+"?r=orders%2Forderinfo%2Fctoorder",//获取发票信息

    addShopCart:serverUrl+"?r=cart%2Fcart%2Faddcart",//添加到购物车
    ShopCartNum:serverUrl+"?r=cart%2Fcart%2Fcartnum",//购物车商品增减
    ShopCartInfo:serverUrl+"?r=cart%2Fcart%2Findex",//获取购物车信息
    ShopCartCheck:serverUrl+"?r=cart%2Fcart%2Fcheck",//购物车选中取消
    ShopCartDelete:serverUrl+"?r=cart%2Fcart%2Fdelcart",//购物车删除
    allCheckUrl:serverUrl+"?r=cart%2Fcart%2Fsetallchecked", //全选、取消全选

    addComment:serverUrl+"?r=comment%2Fcomment%2Faddcomments",//提交评论接口
    uploadUrl:serverUrl+"?r=comment%2Fcomment%2Fupload", //评论图片接口
    getCacheImgUrl:serverUrl+"?r=comment%2Fcomment%2Fzoomcomment",//获取评价缓存图片
    getDelCommentImgUrl:serverUrl+"?r=comment%2Fcomment%2Fdelimage",//删除图片接口
    getLastCommitInfo:serverUrl+"?r=comment%2Fcomment%2Fcommentinfo",//获取最后一条
    getCommentCountUrl:serverUrl+"?r=comment%2Fcomment%2Ftolcomment", //获取评论数量
    getAllCommentUrl:serverUrl+"?r=comment%2Fcomment%2Fcommentlist",//获得所有评论接口

    getShopOrders:serverUrl+"?r=orders%2Forderinfo%2Fctoorder",//购物车生成订单
    getOrderInfo:serverUrl+"?r=orders%2Forderinfo%2Fdtoorder",//直接生成订单

    getIndentInfo:serverUrl+"?r=orders%2Forderinfo%2Findex",//获取订单列表信息
    getConfirmGoods:serverUrl+"?r=orders%2Forderinfo%2Fcheckdelivery",//确认收货
    getIndentDetail:serverUrl+"?r=orders%2Forderinfo%2Fgetorderinfo",//获取订单详情信息
    getOrderStatusDetailURL:serverUrl+"?r=orders%2Forderinfo%2Forderdetail",//获取订单状态详情
    getTiXing:serverUrl+"?r=orders%2Forderinfo%2Fwarm",//提醒发货接口
    getDelIndent:serverUrl+"?r=orders%2Forderinfo%2Forderdel",//删除订单
    getCancelIndent:serverUrl+"?r=orders%2Forderinfo%2Fordercancel", //取消订单

    getAfterSaleGoodsList:serverUrl+"?r=orders%2Fordergoods%2Fgetservice",//获取售后列表
    getAfterSale:serverUrl+"?r=orders%2Fordergoods%2Fcserviceadd",//售后接口
    getAddImg:serverUrl+"?r=orders%2Fordergoods%2Fupload",//售后上传图片
    getDelImgUrl:serverUrl+"?r=orders%2Fordergoods%2Fdelimage",//删除售后图片接口
    getAfterSaleCacheImgUrl:serverUrl+"?r=orders%2Fordergoods%2Fzoomcservice",//获取售后缓存图片

    getCanAllCoupon:serverUrl+"?r=marketing%2Fcoupon%2Fcoupon",//可领取所有优惠券
    allCoupon:serverUrl+"?r=marketing%2Fcoupon%2Fmycouponall",//已领取优惠券
    myCoupon:serverUrl+"?r=marketing%2Fcoupon%2Fmycoupon",//我的优惠券
    getCoupon:serverUrl+"?r=marketing%2Fcoupon%2Fgetcoupon",//已过期的所有优惠券
    getMyCoupon:serverUrl+"?r=marketing%2Fcoupon%2Fachivecoupon",//领取优惠券

    getDaiYanInfo:serverUrl+"?r=marketing%2Fsharereb%2Fgreb",//获取我的代言信息
    getUserRebateMoney:serverUrl+"?r=marketing%2Fsharereb%2Fgreb",//用户获得返利金额
    getUserRebateInfo:serverUrl+"?r=orders%2Fordergoods%2Fordershare",//获得订单用户返利列表
    getOrderRebateInfo:serverUrl+"?r=orders%2Fordergoods%2Fusershare",//单个订单返利详情

    getWuLiuInfo:serverUrl+"?r=orders%2Forderinfo%2Fshowwuliu",//获得物流轨迹
    getWuLiuOrderInfo:serverUrl+"?r=orders%2Forderinfo%2Forderdetail",//订单收货详情

    getTokenInfo:serverUrl+"?r=site%2Fsite%2Freftoken",//获取token
    getUserInfo:serverUrl+"?r=site%2Fsite%2Fgetuserinfo",//获取当前用户信息
    getUserErWeiMa:serverUrl+"?r=site%2Fsite%2Fgeterwurl",// 获取当前用户二维码信息
    getRefUserInfo:serverUrl+"?r=site%2Fsite%2Fgetrefuser",//获取推荐人信息
    getIsJoin:serverUrl+"?r=marketing%2Fsharereb%2Fisjoin",//获取是否已经参加返利活动

    getHuoDongInfo:serverUrl+"?r=marketing%2Fsharereb%2Fsortusershareb"//获取活动页面信息
};
//工具
var nUtils = {
    getUrlParam: function (name) {//获取URL参数
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = decodeURIComponent(window.location.search).substr(1).match(reg); //匹配目标参数
        if (r != null) return unescape(r[2]);
        return null; //返回参数值
    },
    checkTel: function (mobile) {
        //var reg = /^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/;
       var reg =  /^1[34578]\d{9}$/;
        if (reg.test(mobile) == false) {
            return false;
        } else {
            return true;
        }
    },
    checkName: function (uName) {
        var reg = /^[\u4e00-\u9fa5_a-zA-Z0-9]+$/;
        if (reg.test(uName) == false) {
            return false;
        } else {
            return true;
        }
    },
    dateFormat:function(time){//时间格式化  年月日
        if(time){
            time = parseInt(time);
            var date = new Date(time);
            var month = nUtils.formatNum(date.getMonth()+1);
            var dd = nUtils.formatNum(date.getDate());
            return date.getFullYear()+"-"+(month)+"-"+dd;
        }
    },
    dateType:function(time){//时间格式化  年.月.日
        if(time){
            time = parseInt(time);
            var date = new Date(time);
            var month = nUtils.formatNum(date.getMonth()+1);
            var dd = nUtils.formatNum(date.getDate());
            return date.getFullYear()+"."+(month)+"."+dd;
        }
    },
    formatNum:function(data){//格式化数字 小于10的补0
      return   data<10?("0"+data):data;
    },
    dateTime:function(time){//时间格式化  年月日时分
        if(time){
            time = parseInt(time);
            var date = new Date(time);
            var month = nUtils.formatNum(date.getMonth()+1);
            var dd = nUtils.formatNum(date.getDate());
            var hh = nUtils.formatNum(date.getHours()+1);
            var mm = nUtils.formatNum(date.getMinutes());
            return date.getFullYear()+"-"+(month)+"-"+dd+" "+ hh+":"+mm;
        }
    },
    dateTimeDetail:function(time){//时间格式化  年月日时分秒
        if(time){
            time = parseInt(time);
            var date = new Date(time);
            var month = nUtils.formatNum(date.getMonth()+1);
            var dd = nUtils.formatNum(date.getDate());
            var hh = nUtils.formatNum(date.getHours()+1);
            var mm = nUtils.formatNum(date.getMinutes());
            var ss = nUtils.formatNum(date.getSeconds());
            return date.getFullYear()+"-"+(month)+"-"+dd+" "+ hh+":"+mm+":"+ss
        }
    },
    getDateTimeDetail:function(time){//时间格式化  年月日时分秒
        if(time){
            time = parseInt(time);
            var date = new Date(time);
            var hh = nUtils.formatNum(date.getHours()+1);
            var mm = nUtils.formatNum(date.getMinutes());
            return date.getFullYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日 "+ hh +":"+mm
        }
    },
    checkEmail: function (email) { //邮箱格式化
        var reg = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
        if (reg.test(email) == false) {
            return false;
        } else {
            return true;
        }
    },
    onLine:function() {  //断网刷新
        var toastLoading = new auiToast({});
        toastLoading.loading({
            title: "努力加载中",
            duration: 3000
        }, function (ret) {
            console.log(ret);
            setTimeout(function () {
                window.location.reload();
                toastLoading.hide();
            }, 3000)
        });
    }
}

var userInfo = {//用户信息
    userid:"cbfd32b0-e0a6-11e7-8d1e-919a3cee6228",// window.localStorage.getItem("userid")//微信用户id
    openid:"o0NVevyCkCI7jR6cLMlIz8XjTy34",// window.localStorage.getItem("openid")
    access_token:"d902c3ce47124c66ce615d5ad9ba304f",//window.localStorage.getItem("access_token"),
    shopCartId:"0c0bdb10-dbf1-11e7-95f7-0d24801fd345",//购物车id
    //referrerId:window.localStorage.getItem("refereid"),//推荐人Id
    couponId:"2eb61e00-d67e-11e7-bd4e-3fb77d7793b3",//优惠券id
}